package demo.security.core.social.qq.config;

import demo.security.core.props.QQSocialProperties;
import demo.security.core.props.SecurityProperties;
import demo.security.core.social.SocialConfig;
import demo.security.core.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;

/**
 * QQSocialConfig
 *
 * @author lidj
 * @date 2018-02-06
 */
@Configuration
@ConditionalOnProperty(prefix = "demo.security.socialProperties.qqSocialProperties",name = "appId")
public class QQSocialConfig extends SocialConfig {

    @Autowired
    private SecurityProperties securityProperties;

    @Override
    protected ConnectionFactory<?> createConnectionFactory() {
        QQSocialProperties qqSocialProperties = securityProperties.getSocialProperties().getQqSocialProperties();
        return new QQConnectionFactory(qqSocialProperties.getProviderId(),qqSocialProperties.getAppId(),qqSocialProperties.getAppSecret());
    }
}
